home *** CD-ROM | disk | FTP | other *** search
/ Almathera Ten Pack 3: CDPD 3 / Almathera Ten on Ten - Disc 3: CDPD3.iso / fish / 726-750 / 741 / rkrm_lib1 / rkrm_lib1.lha / Intuition / Images_Text / intuitext.c < prev    next >
C/C++ Source or Header  |  1992-09-03  |  5KB  |  132 lines

  1. ;/* intuitext.c - Execute me to compile me with SAS C 5.10
  2. LC -b1 -cfistq -v -y -j73 intuitext.c
  3. Blink FROM LIB:c.o,intuitext.o TO intuitext LIBRARY LIB:LC.lib,LIB:Amiga.lib
  4. quit
  5. */
  6.  
  7. /*
  8. Copyright (c) 1992 Commodore-Amiga, Inc.
  9.  
  10. This example is provided in electronic form by Commodore-Amiga, Inc. for
  11. use with the "Amiga ROM Kernel Reference Manual: Libraries", 3rd Edition,
  12. published by Addison-Wesley (ISBN 0-201-56774-1).
  13.  
  14. The "Amiga ROM Kernel Reference Manual: Libraries" contains additional
  15. information on the correct usage of the techniques and operating system
  16. functions presented in these examples.  The source and executable code
  17. of these examples may only be distributed in free electronic form, via
  18. bulletin board or as part of a fully non-commercial and freely
  19. redistributable diskette.  Both the source and executable code (including
  20. comments) must be included, without modification, in any copy.  This
  21. example may not be published in printed form or distributed with any
  22. commercial product.  However, the programming techniques and support
  23. routines set forth in these examples may be used in the development
  24. of original executable software products for Commodore Amiga computers.
  25.  
  26. All other rights reserved.
  27.  
  28. This example is provided "as-is" and is subject to change; no
  29. warranties are made.  All use is at your own risk. No liability or
  30. responsibility is assumed.
  31. */
  32.  
  33.  
  34. /*
  35. ** intuitext.c - program to show the use of an Intuition IntuiText object.
  36. */
  37. #define INTUI_V36_NAMES_ONLY
  38.  
  39. #include <exec/types.h>
  40. #include <intuition/intuition.h>
  41.  
  42. #include <clib/exec_protos.h>
  43. #include <clib/dos_protos.h>
  44. #include <clib/intuition_protos.h>
  45.  
  46. #include <stdio.h>
  47.  
  48. #ifdef LATTICE
  49. int CXBRK(void)    { return(0); }  /* Disable Lattice CTRL/C handling */
  50. int chkabort(void) { return(0); }  /* really */
  51. #endif
  52.  
  53. struct Library *IntuitionBase = NULL;
  54.  
  55. #define MYTEXT_LEFT (0)
  56. #define MYTEXT_TOP  (0)
  57.  
  58. /*
  59. ** main routine. Open required library and window and draw the images.
  60. ** This routine opens a very simple window with no IDCMP.  See the
  61. ** chapters on "Windows" and "Input and Output Methods" for more info.
  62. ** Free all resources when done.
  63. */
  64. VOID main(int argc, char **argv)
  65. {
  66. struct Screen    *screen;
  67. struct DrawInfo  *drawinfo;
  68. struct Window    *win;
  69. struct IntuiText  myIText;
  70. struct TextAttr   myTextAttr;
  71.  
  72. ULONG myTEXTPEN;
  73. ULONG myBACKGROUNDPEN;
  74.  
  75. IntuitionBase = OpenLibrary("intuition.library",37);
  76. if (IntuitionBase)
  77.     {
  78.     if (screen = LockPubScreen(NULL))
  79.         {
  80.         if (drawinfo = GetScreenDrawInfo(screen))
  81.             {
  82.             /* Get a copy of the correct pens for the screen.
  83.             ** This is very important in case the user or the
  84.             ** application has the pens set in a unusual way.
  85.             */
  86.             myTEXTPEN = drawinfo->dri_Pens[TEXTPEN];
  87.             myBACKGROUNDPEN  = drawinfo->dri_Pens[BACKGROUNDPEN];
  88.  
  89.             /* create a TextAttr that matches the specified font. */
  90.             myTextAttr.ta_Name  = drawinfo->dri_Font->tf_Message.mn_Node.ln_Name;
  91.             myTextAttr.ta_YSize = drawinfo->dri_Font->tf_YSize;
  92.             myTextAttr.ta_Style = drawinfo->dri_Font->tf_Style;
  93.             myTextAttr.ta_Flags = drawinfo->dri_Font->tf_Flags;
  94.  
  95.             /* open a simple window on the workbench screen for displaying
  96.             ** a text string.  An application would probably never use such a
  97.             ** window, but it is useful for demonstrating graphics...
  98.             */
  99.             if (win = OpenWindowTags(NULL,
  100.                                 WA_PubScreen,    screen,
  101.                                 WA_RMBTrap,      TRUE,
  102.                                 TAG_END))
  103.                 {
  104.                 myIText.FrontPen    = myTEXTPEN;
  105.                 myIText.BackPen     = myBACKGROUNDPEN;
  106.                 myIText.DrawMode    = JAM2;
  107.                 myIText.LeftEdge    = MYTEXT_LEFT;
  108.                 myIText.TopEdge     = MYTEXT_TOP;
  109.                 myIText.ITextFont   = &myTextAttr;
  110.                 myIText.IText       = "Hello, World.  ;-)";
  111.                 myIText.NextText    = NULL;
  112.  
  113.                 /* Draw the text string at 10,10 */
  114.                 PrintIText(win->RPort,&myIText,10,10);
  115.  
  116.                 /* Wait a bit, then quit.
  117.                 ** In a real application, this would be an event loop,
  118.                 ** like the one described in the Intuition Input and
  119.                 ** Output Methods chapter.
  120.                 */
  121.                 Delay(200);
  122.  
  123.                 CloseWindow(win);
  124.                 }
  125.             FreeScreenDrawInfo(screen,drawinfo);
  126.             }
  127.         UnlockPubScreen(NULL,screen);
  128.         }
  129.     CloseLibrary(IntuitionBase);
  130.     }
  131. }
  132.